home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / dom / nsIScriptObjectOwner.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  5KB  |  138 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsIScriptObjectOwner_h__
  39. #define nsIScriptObjectOwner_h__
  40.  
  41. #include "nsISupports.h"
  42. #include "nsIScriptContext.h"
  43. #include "nsAString.h"
  44.  
  45. #define NS_ISCRIPTOBJECTOWNER_IID \
  46. { /* 8f6bca7e-ce42-11d1-b724-00600891d8c9 */ \
  47. 0x8f6bca7e, 0xce42, 0x11d1, \
  48.   {0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} } \
  49.  
  50. /**
  51.  * Creates a link between the script object and its native implementation
  52.  *<P>
  53.  * Every object that wants to be exposed in a script environment should
  54.  * implement this interface. This interface should guarantee that the same
  55.  * script object is returned in the context of the same script.
  56.  * <P><I>It does have a bit too much java script information now, that
  57.  * should be removed in a short time. Ideally this interface will be
  58.  * language neutral</I>
  59.  */
  60. class nsIScriptObjectOwner : public nsISupports {
  61. public:
  62.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCRIPTOBJECTOWNER_IID)
  63.   /**
  64.    * Return the script object associated with this object.
  65.    * Create a script object if not present.
  66.    *
  67.    * @param aContext the context the script object has to be created in
  68.    * @param aScriptObject on return will contain the script object
  69.    *
  70.    * @return nsresult NS_OK if the script object is successfully returned
  71.    *
  72.    **/
  73.   NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) = 0;
  74.  
  75.   /**
  76.    * Set the script object associated with this object.
  77.    * Often used to either reset the object to null or initially
  78.    * set it in cases where the object comes before the owner.
  79.    *
  80.    * @param aScriptObject the script object to set
  81.    *
  82.    * @return nsresult NS_OK if the script object is successfully set
  83.    *
  84.    **/
  85.   NS_IMETHOD SetScriptObject(void* aScriptObject) = 0;
  86. };
  87.  
  88. class nsIAtom;
  89.  
  90. #define NS_ISCRIPTEVENTHANDLEROWNER_IID \
  91. { /* 2ad54ae0-a839-11d3-ba97-00104ba02d3d */ \
  92. 0x2ad54ae0, 0xa839, 0x11d3, \
  93.   {0xba, 0x97, 0x00, 0x10, 0x4b, 0xa0, 0x2d, 0x3d} }
  94.  
  95. /**
  96.  * Associate a compiled event handler with its target object, which owns it
  97.  * This is an adjunct to nsIScriptObjectOwner that nsIEventListenerManager's
  98.  * implementation queries for, in order to avoid recompiling a recurrent or
  99.  * prototype-inherited event handler.
  100.  */
  101. class nsIScriptEventHandlerOwner : public nsISupports
  102. {
  103. public:
  104.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCRIPTEVENTHANDLEROWNER_IID)
  105.  
  106.   /**
  107.    * Compile the specified event handler, and bind it to aTarget using
  108.    * aContext.
  109.    *
  110.    * @param aContext the context to use when creating event handler
  111.    * @param aTarget the object to which to bind the event handler
  112.    * @param aName the name of the handler
  113.    * @param aBody the handler script body
  114.    * @param aURL the URL or filename for error messages
  115.    * @param aLineNo the starting line number of the script for error messages
  116.    * @param aHandler the compiled, bound handler object
  117.    */
  118.   virtual nsresult CompileEventHandler(nsIScriptContext* aContext,
  119.                                        void* aTarget,
  120.                                        nsIAtom *aName,
  121.                                        const nsAString& aBody,
  122.                                        const char* aURL,
  123.                                        PRUint32 aLineNo,
  124.                                        void** aHandler) = 0;
  125.  
  126.   /**
  127.    * Retrieve an already-compiled event handler that can be bound to a
  128.    * target object using a script context.
  129.    *
  130.    * @param aName the name of the event handler to retrieve
  131.    * @param aHandler the compiled event handler
  132.    */
  133.   virtual nsresult GetCompiledEventHandler(nsIAtom *aName,
  134.                                            void** aHandler) = 0;
  135. };
  136.  
  137. #endif // nsIScriptObjectOwner_h__
  138.